<template>
  <div class="register-wrap">
    <el-form label-position="left" :model="ruleForm" ref="ruleForm" label-width="0px"
             class="demo-ruleForm login-container">
      <h3 class="title">用户注册</h3>
      <el-form-item prop="username">
        <el-input type="text" v-model="ruleForm.userName" auto-complete="off" placeholder="用户昵称"></el-input>
      </el-form-item>
      <el-form-item prop="account">
        <el-input type="text" v-model="ruleForm.account" auto-complete="off" placeholder="账号"></el-input>
      </el-form-item>
      <el-form-item prop="age">
        <el-input-number type="text" v-model="ruleForm.age"  auto-complete="off" placeholder="年龄"></el-input-number>
      </el-form-item>
      <el-form-item prop="sex">
        <el-select type="text" v-model="ruleForm.sex" auto-complete="off" placeholder="性别">
          <el-option label="男" value="男"></el-option>
          <el-option label="女" value="女"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item prop="roleId">
        <el-select type="text" v-model="ruleForm.roleId" auto-complete="off" placeholder="角色">
          <el-option label="文件管理" value="3"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item prop="phone">
        <el-input type="text" v-model="ruleForm.phone" auto-complete="off" placeholder="电话"></el-input>
      </el-form-item>

      <el-form-item prop="password">
        <el-input type="password" v-model="ruleForm.password" auto-complete="off" placeholder="密码"></el-input>
      </el-form-item>
      <el-form-item style="width:100%;">
        <el-button type="primary" style="width:100%;" @click="submitForm()" :loading="logining">注册</el-button>
      </el-form-item>

    </el-form>
  </div>
</template>
<script type="text/ecmascript-6">
import {addUserInfo} from "../api/basisMG";

export default {
  name: 'register',
  data() {
    return {
      ruleForm: {
        userName: '',
        age: 18,
        sex: '',
        roleId: null,
        roleName: '',
        orgId: null,
        phone: '',
        password: '',
        account: ''
      },

    }
  },
  created() {

  },
  methods: {
    submitForm(){
      let requestData={
        requestData:JSON.stringify([this.ruleForm])
      }
      addUserInfo(requestData).then(resp=>{
        if(resp.body.responseData.status==0){
          this.$message({
            type: 'success',
            message: '用户注册成功！'
          })
        }
        else {
          this.$message({
            type: 'info',
            message: '注册失败！'
          })
        }
      })
    }
  }
}
</script>
<style scoped>
.register-wrap {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding-top: 10%;
  background-image: url();
  /* background-color: #112346; */
  background-repeat: no-repeat;
  background-position: center right;
  background-size: 100%;
}

.login-container {
  border-radius: 10px;
  margin: 0px auto;
  width: 350px;
  padding: 30px 35px 15px 35px;
  background: #fff;
  border: 1px solid #eaeaea;
  text-align: left;
  box-shadow: 0 0 20px 2px rgba(0, 0, 0, 0.1);
}

.title {
  margin: 0px auto 40px auto;
  text-align: center;
  color: #505458;
}

</style>
